<?php
/**
 * Created by PhpStorm.
 * User: ytlmi
 * Date: 2018/3/7
 * Time: 11:15
 */

namespace org\util\forensictool;

use org\util\forensictool\forensicreport\BaseReport;

class WriteReport
{
    protected static $instance;// 对象实例

    /**
     * @return WriteReport
     * 单例模式实例化当前类
     */
    static public function instance()
    {
        if (is_null(self::$instance)) {
            self::$instance = new static();
        }
        return self::$instance;
    }

    /**
     * @param array $caseData 案件数据
     * @return BaseReport|false
     * @throws \Exception
     */
    public function setCaseData($caseData)
    {
        if(!isset($caseData['case_type'])) throw new \Exception('案件信息错误，缺少案件类型信息');
        $className='org\util\forensictool\forensicreport\Report'.$caseData['case_type'];
        if(class_exists($className)){
            return $className::instance()->setCaseData($caseData);
        }else{
            throw new \Exception('错误的案件类型：'.$caseData['case_type']);
        }
    }

}